package com.bxd.baodan.list;

import android.content.Intent;
import android.view.View;

import com.google.gson.reflect.TypeToken;
import com.bxd.baodan.App;
import com.bxd.baodan.R;
import com.bxd.baodan.activity.WebViewPager;
import com.bxd.baodan.adapter.ViewHolder;
import com.bxd.baodan.app.JsonApi;
import com.bxd.baodan.base.BaseListFragment;
import com.bxd.baodan.item.XueTangItem;
import com.bxd.baodan.util.GlideUtil;
import com.bxd.baodan.util.NetUtil;
import com.bxd.baodan.widget.ShapedImageView;
import com.umeng.analytics.MobclickAgent;

import java.lang.reflect.Type;
import java.util.List;

/**
 * Created by lizhichao on 17/7/26.
 */

public class XTangCollectFragment extends BaseListFragment<XueTangItem.DataItem.XueTangBean> {


    @Override
    protected Type getTypeToken() {
        return new TypeToken<List<XueTangItem.DataItem.XueTangBean>>() {
        }.getType();
    }


    @Override
    protected void preDone(View v) {
        footer = View.inflate(getActivity(),R.layout.collect_null_footer,null);
        autoRefresh();
    }

    @Override
    protected int getFragmentLayout() {

        return R.layout.pull_refresh_layout_no_divider;
    }


    @Override
    public void setUsualNetUtil() {
        netUtil = new NetUtil(getActivity(), JsonApi.article_mycollect);

    }

    @Override
    protected int getItemLayout() {


        return R.layout.xuetang_item;
    }

    @Override
    protected void convert(ViewHolder holder, final XueTangItem.DataItem.XueTangBean item) {


        GlideUtil.loadImage(context, item.image, (ShapedImageView) holder.getView(R.id.img));
        holder.setText(R.id.title, item.title);


        holder.getView(R.id.main).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                MobclickAgent.onEvent(App.getContext(), "v6_1_3_WD_wdsc_wz_wzxq");
                Intent intent = new Intent(App.getContext(), WebViewPager.class);

                    intent.putExtra("startUrl", item.url);

                startActivity(intent);


            }
        });
    }


    @Override
    protected String getArrayStr(String json_data) {
        return "list";
    }
}
